-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc++] Fix use of static in constexpr #160180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc++] Fix use of static in constexpr #160180
Conversation
`static` is not allowed inside constexpr functions in C++ versions below 23. This is causing a build error when compiled with GCC and warning when compiled with Clang. This patch fixes this.
@llvm/pr-subscribers-libcxx Author: Prabhu Rajasekaran (Prabhuk) Changes
Full diff: https://github.com/llvm/llvm-project/pull/160180.diff 1 Files Affected:
diff --git a/libcxx/include/__algorithm/make_heap.h b/libcxx/include/__algorithm/make_heap.h
index 8cfeda2b59811..c592656374dac 100644
--- a/libcxx/include/__algorithm/make_heap.h
+++ b/libcxx/include/__algorithm/make_heap.h
@@ -36,7 +36,8 @@ __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
using __diff_t = __iter_diff_t<_RandomAccessIterator>;
const __diff_t __n = __last - __first;
- static const bool __assume_both_children = is_arithmetic<__iter_value_type<_RandomAccessIterator> >::value;
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 const bool __assume_both_children =
+ is_arithmetic<__iter_value_type<_RandomAccessIterator> >::value;
// While it would be correct to always assume we have both children, in practice we observed this to be a performance
// improvement only for arithmetic types.
|
Drop static and constexpr for __assume_both_children. Simply leave it to be plain `const`. Co-authored-by: A. Jiang <de34@live.cn>
@frederick-vs-ja Can you PTAL at the updated patch? This issue is breaking our downstream builders. Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you @frederick-vs-ja |
static
is not allowed inside constexpr functions in C++ versions below23. This is causing a build error when compiled with GCC and warning
when compiled with Clang. This patch fixes this.